package com.mriassl.rabbitmq.unbind;

import java.io.IOException;

import com.mriassl.rabbitmq.base.AbstractProducer;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class MessageProducer extends AbstractProducer {
	
	@Override
	protected void doSometing(Connection conn, Channel channel) throws IOException {
	    channel.exchangeDeclare(Consts.EXCHANGE_NAME, BuiltinExchangeType.DIRECT, false, false, null);
        channel.queueDeclare(Consts.QUEUE_NAME, false, false, false, null);
        channel.queueBind(Consts.QUEUE_NAME, Consts.EXCHANGE_NAME, Consts.ROUTING_KEY);
		int count = 20;
		while(count<29){
			String message = "Hello World! " + count;
			channel.basicPublish(Consts.EXCHANGE_NAME, Consts.ROUTING_KEY, null, message.getBytes());
			System.out.println(" [x] Sent '" + message + "'");
			count++;
		}
	}
	
	public static void main(String[] args) throws Exception {
		MessageProducer plog = new MessageProducer();
		plog.publicMsg();
	}
	
}